program hitdapolygon;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  x, y: array of integer;
  i, n, xp, yp: integer;
  s1, s2, a, b, c, p: real;
begin
  Writeln ('Enter the number of sides here:');
  readln (n);
  setlength (x, n);
  setlength (y, n);
  Writeln ('Enter coordinates of points here:');
  for i:= 0 to n-1 do
    readln (x[i], y[i]);
  Writeln ('Enter coordinates of your polygon peaks:');
  readln (xp, yp);
  s1:=0;
  s2:=0;
  for i:= 0 to n-2 do
  begin
    a:= sqrt(abs(x[i]-x[i+1])*abs(x[i]-x[i+1])+abs(y[i]-y[i+1])*abs(y[i]-y[i+1]));
    b:= sqrt(abs(x[i]-xp)*abs(x[i]-xp)+abs(y[i]-yp)*abs(y[i]-yp));
    c:= sqrt(abs(xp-x[i+1])*abs(xp-x[i+1])+abs(yp-y[i+1])*abs(yp-y[i+1]));
    p:= (a+b+c)/2;
    s1:=s1+sqrt(p*(p-a)*(p-b)*(p-c));
  end;
   a:= sqrt(abs(x[0]-x[n-1])*abs(x[0]-x[n-1])+abs(y[0]-y[n-1])*abs(y[0]-y[n-1]));
   b:= sqrt(abs(x[0]-xp)*abs(x[0]-xp)+abs(y[0]-yp)*abs(y[0]-yp));
   c:= sqrt(abs(xp-x[n-1])*abs(xp-x[n-1])+abs(yp-y[n-1])*abs(yp-y[n-1]));
   p:= (a+b+c)/2;
   s1:=s1+sqrt(p*(p-a)*(p-b)*(p-c));
  for i:= 1 to n-2 do
  begin
    a:= sqrt(abs(x[i]-x[i+1])*abs(x[i]-x[i+1])+abs(y[i]-y[i+1])*abs(y[i]-y[i+1]));
    b:= sqrt(abs(x[i]-x[0])*abs(x[i]-x[0])+abs(y[i]-y[0])*abs(y[i]-y[0]));
    c:= sqrt(abs(x[0]-x[i+1])*abs(x[0]-x[i+1])+abs(y[0]-y[i+1])*abs(y[0]-y[i+1]));
    p:= (a+b+c)/2;
    s2:=s2+sqrt(p*(p-a)*(p-b)*(p-c));
  end;
  If (s2-10<s1) and (s1<s2+10) then writeln ('Point is in your polygon')
             else writeln ('Point is out of  your polygon');
  readln;
end.
